package com.wangzhenyu.learn.test.designPattern

//建造者模式

@Suppress("UNUSED")
object FBuilderPattern {
    @Suppress("UNUSED")
    class Robot private constructor(
        val code: String,
        val battery: String?,
        val height: Int?,
        val weight: Int?
    ) {

        class Builder(private val code: String) {
            private var battery: String? = null
            private var height: Int? = null
            private var weight: Int? = null

            fun setBattery(battery: String): Builder {
                this.battery = battery
                return this
            }

            fun setHeight(height: Int): Builder {
                this.height = height
                return this
            }

            fun setBattery(weight: Int): Builder {
                this.weight = weight
                return this
            }

            fun build(): Robot {
                return Robot(code, battery, height, weight)
            }
        }
    }

}